/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * UDPSendWizardPanel.java
 *
 * Created on 30.06.2010, 23:21:08
 */
package md.shaman.forms.wizard;

import java.awt.Color;
import java.awt.event.ActionListener;
import java.awt.event.KeyListener;
import javax.swing.border.LineBorder;
import md.shaman.protocols.Protocol;

/**
 *
 * @author Shaman
 */
public class GeneralSendReceiveWizardPanel extends javax.swing.JPanel {

    /** Creates new form UDPSendWizardPanel */
    public GeneralSendReceiveWizardPanel() {
        initComponents();
    }

    public boolean isValidate() {
        if (ipAlertLabel.isVisible() || ipPortAlertLabel.isVisible() || nicPortAlertLabel.isVisible()) {
            return false;
        }
        return true;
    }

    public void addValidateEvent(KeyListener l) {
        ipTextField.addKeyListener(l);
        ipPortTextField.addKeyListener(l);
        nicPortTextField.addKeyListener(l);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        ipLabel = new javax.swing.JLabel();
        nicLabel = new javax.swing.JLabel();
        ipTextField = new javax.swing.JTextField();
        nicComboBox = new javax.swing.JComboBox();
        ipPortLabel = new javax.swing.JLabel();
        ipPortTextField = new javax.swing.JTextField();
        nicPortLabel = new javax.swing.JLabel();
        nicPortTextField = new javax.swing.JTextField();
        ipAlertLabel = new javax.swing.JLabel();
        ipPortAlertLabel = new javax.swing.JLabel();
        nicPortAlertLabel = new javax.swing.JLabel();

        setName("Form"); // NOI18N

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(md.shaman.TrafficGeneratorApp.class).getContext().getResourceMap(GeneralSendReceiveWizardPanel.class);
        ipLabel.setText(resourceMap.getString("ipLabel.text")); // NOI18N
        ipLabel.setToolTipText(resourceMap.getString("ipLabel.toolTipText")); // NOI18N
        ipLabel.setName("ipLabel"); // NOI18N

        nicLabel.setText(resourceMap.getString("nicLabel.text")); // NOI18N
        nicLabel.setToolTipText(resourceMap.getString("nicLabel.toolTipText")); // NOI18N
        nicLabel.setName("nicLabel"); // NOI18N

        ipTextField.setText(resourceMap.getString("ipTextField.text")); // NOI18N
        ipTextField.setToolTipText(resourceMap.getString("ipTextField.toolTipText")); // NOI18N
        ipTextField.setName("ipTextField"); // NOI18N
        ipTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                ipTextFieldKeyReleased(evt);
            }
        });

        nicComboBox.setToolTipText(resourceMap.getString("nicComboBox.toolTipText")); // NOI18N
        nicComboBox.setName("nicComboBox"); // NOI18N

        ipPortLabel.setText(resourceMap.getString("ipPortLabel.text")); // NOI18N
        ipPortLabel.setToolTipText(resourceMap.getString("ipPortLabel.toolTipText")); // NOI18N
        ipPortLabel.setName("ipPortLabel"); // NOI18N

        ipPortTextField.setToolTipText(resourceMap.getString("ipPortTextField.toolTipText")); // NOI18N
        ipPortTextField.setName("ipPortTextField"); // NOI18N
        ipPortTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                ipPortTextFieldKeyReleased(evt);
            }
        });

        nicPortLabel.setText(resourceMap.getString("nicPortLabel.text")); // NOI18N
        nicPortLabel.setToolTipText(resourceMap.getString("nicPortLabel.toolTipText")); // NOI18N
        nicPortLabel.setName("nicPortLabel"); // NOI18N

        nicPortTextField.setText(resourceMap.getString("nicPortTextField.text")); // NOI18N
        nicPortTextField.setToolTipText(resourceMap.getString("nicPortTextField.toolTipText")); // NOI18N
        nicPortTextField.setName("nicPortTextField"); // NOI18N
        nicPortTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                nicPortTextFieldKeyReleased(evt);
            }
        });

        ipAlertLabel.setIcon(resourceMap.getIcon("ipAlertLabel.icon")); // NOI18N
        ipAlertLabel.setText(resourceMap.getString("ipAlertLabel.text")); // NOI18N
        ipAlertLabel.setToolTipText(resourceMap.getString("ipAlertLabel.toolTipText")); // NOI18N
        ipAlertLabel.setName("ipAlertLabel"); // NOI18N

        ipPortAlertLabel.setIcon(resourceMap.getIcon("ipPortAlertLabel.icon")); // NOI18N
        ipPortAlertLabel.setToolTipText(resourceMap.getString("ipPortAlertLabel.toolTipText")); // NOI18N
        ipPortAlertLabel.setName("ipPortAlertLabel"); // NOI18N

        nicPortAlertLabel.setIcon(resourceMap.getIcon("nicPortAlertLabel.icon")); // NOI18N
        nicPortAlertLabel.setToolTipText(resourceMap.getString("nicPortAlertLabel.toolTipText")); // NOI18N
        nicPortAlertLabel.setName("nicPortAlertLabel"); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(nicPortLabel)
                        .addGap(306, 306, 306))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(ipLabel)
                            .addComponent(ipPortLabel)
                            .addComponent(nicLabel))
                        .addGap(10, 10, 10)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(nicPortTextField, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 277, Short.MAX_VALUE)
                            .addComponent(nicComboBox, javax.swing.GroupLayout.Alignment.TRAILING, 0, 277, Short.MAX_VALUE)
                            .addComponent(ipPortTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 277, Short.MAX_VALUE)
                            .addComponent(ipTextField, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 277, Short.MAX_VALUE))))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(ipAlertLabel)
                    .addComponent(ipPortAlertLabel)
                    .addComponent(nicPortAlertLabel))
                .addGap(25, 25, 25))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(46, 46, 46)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(ipLabel)
                    .addComponent(ipTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(ipAlertLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(ipPortLabel)
                            .addComponent(ipPortTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(nicLabel)
                            .addComponent(nicComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(ipPortAlertLabel))
                .addGap(7, 7, 7)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(nicPortLabel)
                        .addComponent(nicPortTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(nicPortAlertLabel))
                .addContainerGap(155, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void ipTextFieldKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_ipTextFieldKeyReleased
        ipAlertLabel.setVisible(!Protocol.isInetAddress(ipTextField.getText()));
    }//GEN-LAST:event_ipTextFieldKeyReleased

    private void ipPortTextFieldKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_ipPortTextFieldKeyReleased
        ipPortAlertLabel.setVisible(!Protocol.isInetAddressPort(ipPortTextField.getText()));
    }//GEN-LAST:event_ipPortTextFieldKeyReleased

    private void nicPortTextFieldKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_nicPortTextFieldKeyReleased
        nicPortAlertLabel.setVisible(!Protocol.isInetAddressPort(nicPortTextField.getText()));
    }//GEN-LAST:event_nicPortTextFieldKeyReleased
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel ipAlertLabel;
    private javax.swing.JLabel ipLabel;
    private javax.swing.JLabel ipPortAlertLabel;
    private javax.swing.JLabel ipPortLabel;
    protected javax.swing.JTextField ipPortTextField;
    protected javax.swing.JTextField ipTextField;
    protected javax.swing.JComboBox nicComboBox;
    private javax.swing.JLabel nicLabel;
    private javax.swing.JLabel nicPortAlertLabel;
    private javax.swing.JLabel nicPortLabel;
    protected javax.swing.JTextField nicPortTextField;
    // End of variables declaration//GEN-END:variables
}
